using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class opertblMap : EntityTypeConfiguration<opertbl>
    {
        public opertblMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Category)
                .HasMaxLength(50);

            this.Property(t => t.Subproc)
                .HasMaxLength(10);

            this.Property(t => t.Class)
                .HasMaxLength(50);

            this.Property(t => t.Item)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Doct)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.Surface)
                .HasMaxLength(10);

            this.Property(t => t.Description)
                .HasMaxLength(80);

            this.Property(t => t.location)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.ChartCode)
                .HasMaxLength(20);

            this.Property(t => t.File_Primary_key)
                .HasMaxLength(10);

            this.Property(t => t.Opertbl_Order)
                .HasMaxLength(2);

            this.Property(t => t.Opertbl_INSAuth_NB)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("opertbl");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.AdmID).HasColumnName("AdmID");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.Subproc).HasColumnName("Subproc");
            this.Property(t => t.CustID).HasColumnName("CustID");
            this.Property(t => t.Class).HasColumnName("Class");
            this.Property(t => t.status).HasColumnName("status");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.qty).HasColumnName("qty");
            this.Property(t => t.Toothnb).HasColumnName("Toothnb");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.Doct).HasColumnName("Doct");
            this.Property(t => t.asksurf).HasColumnName("asksurf");
            this.Property(t => t.Surface).HasColumnName("Surface");
            this.Property(t => t.descript).HasColumnName("descript");
            this.Property(t => t.fromch).HasColumnName("fromch");
            this.Property(t => t.Posted).HasColumnName("Posted");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.pcode).HasColumnName("pcode");
            this.Property(t => t.Extended).HasColumnName("Extended");
            this.Property(t => t.note).HasColumnName("note");
            this.Property(t => t.PlanID).HasColumnName("PlanID");
            this.Property(t => t.importpriceflag).HasColumnName("importpriceflag");
            this.Property(t => t.DiscPerc).HasColumnName("DiscPerc");
            this.Property(t => t.DiscAmt).HasColumnName("DiscAmt");
            this.Property(t => t.expirydate).HasColumnName("expirydate");
            this.Property(t => t.location).HasColumnName("location");
            this.Property(t => t.ordqty).HasColumnName("ordqty");
            this.Property(t => t.ChartCode).HasColumnName("ChartCode");
            this.Property(t => t.Bridge_start).HasColumnName("Bridge_start");
            this.Property(t => t.Bridge_end).HasColumnName("Bridge_end");
            this.Property(t => t.SR_M).HasColumnName("SR_M");
            this.Property(t => t.SR_L).HasColumnName("SR_L");
            this.Property(t => t.SR_D).HasColumnName("SR_D");
            this.Property(t => t.SR_B).HasColumnName("SR_B");
            this.Property(t => t.SR_O).HasColumnName("SR_O");
            this.Property(t => t.modifier).HasColumnName("modifier");
            this.Property(t => t.VOID_Removed).HasColumnName("VOID_Removed");
            this.Property(t => t.VR_date).HasColumnName("VR_date");
            this.Property(t => t.VR_User).HasColumnName("VR_User");
            this.Property(t => t.User).HasColumnName("User");
            this.Property(t => t.GID).HasColumnName("GID");
            this.Property(t => t.OPR_DentalLab).HasColumnName("OPR_DentalLab");
            this.Property(t => t.File_Primary_key).HasColumnName("File Primary key");
            this.Property(t => t.OP_Saved).HasColumnName("OP_Saved");
            this.Property(t => t.OP_Note_Closed).HasColumnName("OP_Note_Closed");
            this.Property(t => t.opertbl_PlannedProcedure).HasColumnName("opertbl_PlannedProcedure");
            this.Property(t => t.Opertbl_AuthBy).HasColumnName("Opertbl_AuthBy");
            this.Property(t => t.Opertbl_AuthOn).HasColumnName("Opertbl_AuthOn");
            this.Property(t => t.Opertbl_ApprovedBy).HasColumnName("Opertbl_ApprovedBy");
            this.Property(t => t.Opertbl_ApprovedOn).HasColumnName("Opertbl_ApprovedOn");
            this.Property(t => t.Opertbl_Grade).HasColumnName("Opertbl_Grade");
            this.Property(t => t.Opertbl_Priority).HasColumnName("Opertbl_Priority");
            this.Property(t => t.Opertbl_Completed).HasColumnName("Opertbl_Completed");
            this.Property(t => t.Opertbl_Order).HasColumnName("Opertbl_Order");
            this.Property(t => t.Opertbl_Visit).HasColumnName("Opertbl_Visit");
            this.Property(t => t.Opertbl_Phase).HasColumnName("Opertbl_Phase");
            this.Property(t => t.Opertbl_TimeUnit).HasColumnName("Opertbl_TimeUnit");
            this.Property(t => t.Opertbl_Coverage).HasColumnName("Opertbl_Coverage");
            this.Property(t => t.Opertbl_INSAuth_NB).HasColumnName("Opertbl_INSAuth_NB");

            // Relationships
            this.HasOptional(t => t.PriceLst)
                .WithMany(t => t.opertbls)
                .HasForeignKey(d => d.pcode);

        }
    }
}
